package mysql

import (
	"gorm.io/gorm"
)

type Manuscript struct {
	gorm.Model
	Name    string `gorm:"type:varchar(30);not null;comment:'稿件名'"`
	Content string `gorm:"type:text;not null;comment:'稿件内容'"`
	ClassId int64  `gorm:"type:int(11);not null;comment:'类别id'"`
}

func (m *Manuscript) ManuscriptAdd(db *gorm.DB) error {
	return db.Debug().Create(m).Error
}

//func (m *Manuscript) ManuscriptList(db *gorm.DB, lists []*manuscriprpc.ManuscriptList) []*manuscriprpc.ManuscriptList {
//	/*
//		SELECT
//		  manuscripts.id AS manuscripts_id,
//		  manuscripts.NAME,
//		  content,
//		  classes.name AS classes_name
//		FROM
//		  manuscripts
//		  LEFT JOIN classes ON manuscripts.class_id = classes.id
//	*/
//	db.Debug().Table("manuscripts").
//		Select("manuscripts.id AS manuscripts_id,  manuscripts.name,  content,  classes.name AS classes_name").
//		Joins("JOIN classes ON manuscripts.class_id = classes.id").
//		Find(&lists)
//	return lists
//}
